Use case: DMA2D transfer blending polling mode

Sequence diagram

DMA2D transfer blending polling mode.

@startuml
== DMA2D Initialization and Configuration ==
"Application" -> "DMA2D Driver" : HAL_DMA2D_Init()
"DMA2D Driver" --> "Application" : HAL_OK or HAL_INVALID_PARAM
"Application" -> "DMA2D Driver" : HAL_DMA2D_ConfigLayer(&hdma2d, 0)
"DMA2D Driver" --> "Application" :
"Application" -> "DMA2D Driver" : HAL_DMA2D_ConfigLayer(&hdma2d, 1)
"DMA2D Driver" --> "Application" :
== DMA2D Transfer Process ==
"Application" -> "DMA2D Driver" : HAL_DMA2D_BlendingStart()
"DMA2D Driver" --> "Application" :
"Application" -> "DMA2D Driver" : HAL_DMA2D_PollForTransfer()
"DMA2D Driver" --> "Application" :

@enduml

Code snippet

HAL1

HAL2

DMA2D_HandleTypeDef hdma2d;





/* DMA2D init configuration */
hdma2d.Instance = DMA2D;

hdma2d.Init.Mode = DMA2D_M2M_BLEND;
hdma2d.Init.ColorMode = DMA2D_OUTPUT_ARGB8888;
hdma2d.Init.RedBlueSwap = DMA2D_RB_REGULAR;
hdma2d.Init.OutputOffset = 0x0;
hdma2d.Init.AlphaInverted = DMA2D_REGULAR_ALPHA;
hdma2d.Init.BytesSwap = DMA2D_BYTES_REGULAR;

/* Foreground Configuration */

hdma2d.LayerCfg[1].AlphaMode = DMA2D_REPLACE_ALPHA;
hdma2d.LayerCfg[1].InputAlpha = 0xFF;
hdma2d.LayerCfg[1].InputColorMode = DMA2D_INPUT_RGB565;
hdma2d.LayerCfg[1].InputOffset = 0x0;
hdma2d.LayerCfg[1].RedBlueSwap = DMA2D_RB_REGULAR;
hdma2d.LayerCfg[1].AlphaInverted = DMA2D_REGULAR_ALPHA;

/* Background Configuration */

hdma2d.LayerCfg[0].AlphaMode = DMA2D_REPLACE_ALPHA;
hdma2d.LayerCfg[0].InputAlpha = 0xFF;
hdma2d.LayerCfg[0].InputColorMode = DMA2D_INPUT_RGB565;
hdma2d.LayerCfg[0].InputOffset = 0x0;
hdma2d.LayerCfg[0].RedBlueSwap = DMA2D_RB_REGULAR;
hdma2d.LayerCfg[0].AlphaInverted = DMA2D_REGULAR_ALPHA;


HAL_DMA2D_Init(&hdma2d);
HAL_DMA2D_ConfigLayer(&hdma2d, 0);
HAL_DMA2D_ConfigLayer(&hdma2d, 1);

HAL_DMA2D_BlendingStart(&hdma2d, (uint32_t)&RGB565_64x80_1,
                        (uint32_t)&RGB565_64x80_2,LCD_FRAME_BUFFER, 64, 80);
HAL_DMA2D_PollForTransfer(&hdma2d, 10);
hal_dma2d_handle_t hdma2d;

/* DMA2D initialization */

HAL_DMA2D_Init(&hdma2d, HAL_DMA2D);

/* DMA2D output configuration */

p_config.output.p_dest = (void *) OUTPUT_FRAME_BUFFER;

p_config.output.color_mode = HAL_DMA2D_OUTPUT_COLOR_ARGB8888;

p_config.output.offset = 0x0;



/* Foreground Configuration */
p_config.fg_input.p_src = (void const*) (uint32_t)&RGB565_64x80_1;
p_config.fg_input.alpha_mode   = HAL_DMA2D_INPUT_ALPHA_REPLACE;
p_config.fg_input.alpha_value  = 0xFF;
p_config.fg_input.color_mode   = HAL_DMA2D_INPUT_COLOR_RGB565;
p_config.fg_input.offset   = 0;



/* Background Configuration */
p_config.bg_input.p_src = (void const*) (uint32_t)&RGB565_64x80_2;
p_config.bg_input.alpha_mode   = HAL_DMA2D_INPUT_ALPHA_REPLACE;
p_config.bg_input.alpha_value  = 0xFF;
p_config.bg_input.color_mode   = HAL_DMA2D_INPUT_COLOR_RGB565;
p_config.bg_input.offset   = 0;


p_config.width = 64;
p_config.height = 80;

HAL_DMA2D_SetConfigBlending(&hdma2d, &p_config);


HAL_DMA2D_Start(&hdma2d);
HAL_DMA2D_PollForTransfer(&hdma2d, 10);

Key changes

  1. In HAL2, blending transfers are configured using HAL_DMA2D_SetConfigBlending() and started using HAL_DMA2D_Start().

  2. In HAL1, blending uses a dedicated start API (HAL_DMA2D_BlendingStart()) after layer configuration.